package com.peng.leetcode.swordoffer;

/**
 * Sword5ReplaceSpace
 * 剑指 Offer 05. 替换空格
 * https://leetcode.cn/problems/ti-huan-kong-ge-lcof/
 *
 * @author: lupeng6
 * @create: 2023/3/10 12:38
 */
public class Sword5ReplaceSpace {
    public String replaceSpace(String s) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                builder.append("%20");
            } else {
                builder.append(s.charAt(i));
            }
        }
        return builder.toString();
    }
}
